<template>
    <div class="box">
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        <div></div>
		<div></div>
        <p>{{ loadingText }}</p>
    </div>
</template>

<script>
import { getUUID } from '@/utils'
export default {
  data () {
    return {
      loadingText:'未被授权访问'
    }
  },
  created () {
    this.login()
  },
  methods: {
    login () {
      this.loadingText='正在进入系统...';
      var url = window.location.href
      if (
        url.indexOf('token=') !== -1 &&
        url.indexOf('&') !== -1 &&
        url.indexOf('loginName') !== -1
      ) {
        var s = url.split('token')
        var token = s[1].substr(1, s[1].indexOf('&') - 1)
        var l = url.split('loginName')
        var loginName = l[1].substr(1, l[1].indexOf('&') - 1)
        // 判断token 是否为空
        if (token.length > 0 && loginName.length > 0) {
          this.$http({
            url: this.$http.adornUrl('/sys/tokenlogin'),
            method: 'get',
            params: {
              token: token,
              name: loginName
            }
          }).then(({ data }) => {
            if (data && data.code === 0) {
              this.$cookie.set('token', data.token)
              sessionStorage.setItem('user', JSON.stringify(data.user))
              sessionStorage.setItem('company', JSON.stringify(data.user.company))
              this.$router.replace({ name: 'home' })
            }else{
              this.loadingText='未被授权访问';
            }
          })
        }
      }
      this.loadingText='未被授权访问';
    }
  }
}
</script>

<style lang="scss">
.box{
	width: 305px;
    height: 125px;
    border: 1px solid #f6f6f6;
    -webkit-box-shadow: 0px 0px 5px #eeebeb;
    box-shadow: 0px 0px 5px #eeeded;
    margin: 200px auto 0;
    color: #b8c4cb;
}

.box p{
	text-align: center;
	width:100%;
	float:left;
	margin:0;
	padding:0;
	font-size:14px;
}

.box div{
	width:20px;
	height:50px;
	margin:15px;
	float: left;
	background-color: hotpink;
	border-radius:10px;
}

.box div:nth-child(1){
	background-color: lightcoral;
	animation: loading 0.5s ease 0s infinite alternate;
}
.box div:nth-child(2){
	background-color: darkorange;
	animation: loading 0.5s ease 0.1s infinite alternate;
}
.box div:nth-child(3){
	background-color: lightcoral;
	animation: loading 0.5s ease 0.2s infinite alternate;
}
.box div:nth-child(4){
	background-color: gold;
	animation: loading 0.5s ease 0.3s infinite alternate;
}
.box div:nth-child(5){
	background-color: burlywood;
	animation: loading 0.5s ease 0.4s infinite alternate;
}
.box div:nth-child(6){
	animation: loading 0.5s ease 0.5s infinite alternate;
}

@keyframes loading{
	from{
		transform:scaleY(1)
	}
	to{
		transform: scaleY(0.5);
	}
}
</style>
